- /* sdfsindv.cpp by K.Tsuru */
- // function ID 3208 DRADIX
- /****************************************************************
- SDouble class
- sin x for |x| < pi/4
- The divide method is used similar to that used in Exp(x).
- x is divided into the sum
- x = a(short number)+b(long but very small number)
- and the addition theorem
- sin(a+b) = cos(a)*sin(b) + sin(a)*cos(b)
- is used.Combining with SinRN (x/(R^N) method) it becomes slower.
- ****************************************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- SDouble SinDiv(const SDouble& x){
- // seriesFig : The change of this value refering the number of effective figures
- //yields the same speed or slower.
- const uint seriesFig = 4u;
- if(x.RdxExp() < -(int)seriesFig) return SinSeries(x); // |x| << 1.0
-
- SDouble a, b(x), y;
- //It takes out upper 'seriesFig' figures.
- // x = a+b, sin(x) = sin(a+b) = cos(a)*sin(b) + sin(a)*cos(b)
- if(x.Sign() < 0) b.ChangeSign(); // b = |x|
- a = b.TakeOutFigures(seriesFig);
- b -= a;
- if( b.Sign(3208) ){
- //Comparing 'SinSeries' an enough precision can be obtained.
- RealSize C;
- C.SetEffFig(x.EffFig() -seriesFig); //It can reduce the number of effective figures.
- b = SinSeries(b);
- C.SetEffFig(0);
- C.SetEffFig(x.EffFig() + 2u, C.TEMP_EXTEND);
- a = CosSeries(a);
- y = a*b + Sqrt((ONE - a*a)*(ONE - b*b));
- C.SetEffFig(0);
- y.Reform(3208);
- } else y = SinSeries(a); // b = 0 for short x.
- if(x.Sign() < 0) y.ChangeSign();
- return y;
- }
sdfsindv.cpp : last modifiled at 2017/09/05 16:16:44(1,500 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).